package com.example.zyh.controller;


import com.example.zyh.pojo.Home;
import com.example.zyh.service.Impl.HomeServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@ResponseBody
public class HomeController {
    @Resource
    private HomeServiceImpl homeService;
    @RequestMapping("/home/list")
    public List<Home> select(){
        return homeService.select();
    }
    @RequestMapping("/home/del")
    public void delete(int id){
        homeService.delete(id);
    }
    @RequestMapping("/home/add")
    public void add(Home home){

        homeService.add(home);
    }

    @RequestMapping("/home/update")
    public void update(Home home){
        homeService.update(home);
    }
    @RequestMapping("/home/selectlike")
    public List<Home> selectlike(Home home){
        if(home.getNumber() == null){
            home.setNumber("");
        }
        if(home.getBuild()==null){
            home.setBuild(" ");
        }
        if(home.getLouceng()==null){
            home.setLouceng(" ");
        }
        if(home.getWmeter()==null){
            home.setWmeter(" ");
        }
        if(home.getWlocation()==null){
            home.setWlocation(" ");
        }
        if(home.getEmeter()==null){
            home.setEmeter(" ");
        }
        if(home.getElocation()==null){
            home.setElocation(" ");
        }
        if(home.getArea()==null){
            home.setArea(" ");
        }
        if(home.getCarea()==null){
            home.setCarea(" ");
        }
        if(home.getState()==null){
            home.setState(" ");
        }
        if(home.getSit()==null){
            home.setSit(" ");
        }
        if(home.getIntime()==null){
            home.setIntime(" ");
        }
        if(home.getTotime()==null){
            home.setTotime(" ");
        }
       return   homeService.selectlike(home);
    }

}
